package com.michael.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
@AllArgsConstructor
public enum SwitchEnum {
    OPEN(1, "开"),
    CLOSE(0, "关");

    private final Integer type;

    private final String desc;

    public static SwitchEnum of(Integer type) {
        if (type == null) {
            return null;
        }
        Optional<SwitchEnum> any =
                Arrays.stream(SwitchEnum.values()).filter(x -> x.getType().equals(type)).findAny();
        return any.orElse(null);
    }
}
